home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / syn_cam.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  10KB  |  241 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. //  SYN_CAM.H - Synthetic Camera Class Include File
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    94/08/23 - Version 1.00A release.
  8. //              94/10/12 - Removed EnableGamma function call
  9. //                         from SynCamera constructor.
  10. //                       - Added IntensityFlag,
  11. //                         GetIntensity, DisableIntensity,
  12. //                         EnableIntensity and SetIntensity
  13. //                         functions.
  14. //              94/10/14 - Added ContrastFlag, GetContrast,
  15. //                         DisableContrast, EnableContrast
  16. //                         and SetContrast functions.
  17. //              94/11/26 - Modified Preview and Shoot
  18. //                         function prototypes.
  19. //                       - Changed "instance.h" include
  20. //                         directive to "environ.h".
  21. //                       - Added Shade function prototype.
  22. //              94/12/16 - Version 1.01A release.
  23. //              95/02/05 - Version 1.02A release.
  24. //              95/03/21 - Added OpenBuffer, CloseBuffer,
  25. //                         InstBartlettFilter, GetMaxPass,
  26. //                         GetNumFilters, GetCurrFilterName,
  27. //                         GetCurrFilterSize, GetFilterName
  28. //                         and RenderPolygons function
  29. //                         prototypes.
  30. //                       - Added AntiAliasFlag, GetNumPass
  31. //                         and SetFilterType functions.
  32. //                       - Added Bartlett and BartParam
  33. //                         data structures.
  34. //                       - Added pabuf, pbart, num_sub,
  35. //                         pass, fp_flag and BartlettParam
  36. //                         data members.
  37. //              95/03/25 - Added "c_jitter.h" and "gamma.h"
  38. //                         include directives.
  39. //                       - Added jitter_flag and gamma_flag
  40. //                         gamma_flag data members.
  41. //                       - Added gamma and jitter members.
  42. //                       - Added gamma_flag, jitter_flag,
  43. //                         pass and fp_flag initialization
  44. //                         to SynCamera constructor.
  45. //                       - Modified DisableGamma,
  46. //                         DisableJitter, EnableGamma,
  47. //                         EnableJitter, GammaFlag,
  48. //                         GetGamma, GetNoiseLevel,
  49. //                         GetStatus, JitterFlag, SetGamma
  50. //                         and SetNoiseLevel functions.
  51. //                       - Added SC_SuperRes enum constants.
  52. //                       - Modified Shoot function
  53. //                         prototype.
  54. //              95/06/17 - Added color_type data member to
  55. //                         SynCamera.
  56. //                       - Modified GetColorType and
  57. //                         SetColorType functions.
  58. //                       - Added color_type initialization
  59. //                         to SynCamera constructor.
  60. //                       - Added SC_RGB, SC_MONO and
  61. //                         SC_PSEUDO definitions.
  62. //              95/06/28 - Added Reset function prototype.
  63. //              95/07/21 - Version 1.02B release.
  64. //              96/02/14 - Version 1.02C release.
  65. //              96/02/21 - Added Abort function prototype.
  66. //              96/03/30 - Deleted vdv_horz, vdv_vert,
  67. //                         vup_horz and vup_vert data
  68. //                         members from SynCamera.
  69. //                       - Removed view director vector and
  70. //                         view-up vector initialization
  71. //                         from SynCamera constructor.
  72. //                       - Deleted GetViewDirHorz,
  73. //                         GetViewDirVert, GetViewUpHorz,
  74. //                         and GetViewUpVert functions from
  75. //                         SynCamera.
  76. //                       - Deleted SetViewDirVector and
  77. //                         and SetViewUpVector functions
  78. //                         from SynCamera.
  79. //                       - Deleted "environ.h" include
  80. //                         directive.
  81. //              96/04/01 - Version 1.03A release.
  82. //
  83. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  84. //              Borland C++ Version 4.5
  85. //
  86. //  Author:     Ian Ashdown, P.Eng.
  87. //              byHeart Software Limited
  88. //              620 Ballantree Road
  89. //              West Vancouver, B.C.
  90. //              Canada V7S 1W3
  91. //              Tel. (604) 922-6148
  92. //              Fax. (604) 987-7621
  93. //
  94. //  Copyright 1994-1996 byHeart Software Limited
  95. //
  96. //  The following source code has been derived from:
  97. //
  98. //    Ashdown, I. 1994. Radiosity: A Programmer's
  99. //    Perspective. New York, NY: John Wiley & Sons.
  100. //
  101. //  It may be freely copied, redistributed, and/or modified
  102. //  for personal use ONLY, as long as the copyright notice
  103. //  is included with all source code files.
  104. //
  105. ////////////////////////////////////////////////////////////
  106.  
  107. #ifndef _SYN_CAM_H
  108. #define _SYN_CAM_H
  109.  
  110. #include "p_clip4.h"
  111. #include "gamma.h"
  112. #include "c_jitter.h"
  113. #include "p_render.h"
  114. #include "win_meta.h"
  115. #include "bitmap24.h"
  116. #include "view_sys.h"
  117.  
  118. // Supersampling resolution identifiers
  119. enum SC_SuperRes
  120. { SC_None, SC_Bartlett_3, SC_Bartlett_5, SC_Bartlett_7 };
  121.  
  122. // Color type definitions
  123. static const int SC_RGB = 0;       // RGB color
  124. static const int SC_MONO = 1;      // Grayscale
  125. static const int SC_PSEUDO = 2;    // Pseudocolor
  126.  
  127. // Extents fill factor
  128. static const double SC_FILL_FACTOR = 0.9;
  129.  
  130. struct Bartlett         // Bartlett filter element
  131. {
  132.   double x_offset;      // x-axis subpixel offset
  133.   double y_offset;      // y-axis subpixel offset
  134.   int alpha;            // Subpixel blend coefficient
  135.   int beta;             // Pixel blend coefficient
  136.   int weight;           // Subpixel weight
  137. };
  138.  
  139. struct BartParam        // Bartlett filter parameters
  140. {
  141.   double offset;        // Subpixel offset
  142.   int width;            // Filter array width
  143.   char *psize;          // Filter size pointer
  144.   char *pname;          // Filter name pointer
  145. };
  146.  
  147. class SynCamera : public ViewSys        // Synthetic camera
  148. {
  149.   private:
  150.     int color_type;         // Display color type
  151.     int height;             // Window height
  152.     int width;              // Window width
  153.     int num_sub;            // Number of subpixels
  154.     int pass;               // Number of passes
  155.     int ss_res;             // Supersampling resolution
  156.     BOOL fp_flag;           // First pass flag
  157.     BOOL gamma_flag;        // Gamma correction flag
  158.     BOOL jitter_flag;       // Color reduction flag
  159.     Bartlett *pbart;        // Bartlett filter pointer
  160.     ColorJitter jitter;     // Color reduction filter
  161.     ColorRGB **pabuf;       // Antialiasing buffer pointer
  162.     Gamma gamma;            // Gamma correction object
  163.     PolyClip4 clipper;      // Polygon clipper
  164.     PolyRender renderer;    // Polygon renderer
  165.  
  166.     // Bartlett filter parameters array
  167.     static BartParam BartlettParam[];
  168.  
  169.     BOOL InstBartlettFilter();
  170.     BOOL OpenBuffer( WinBitmap * );
  171.     void CloseBuffer();
  172.     void RenderPolygons( Environ *, int, double, double );
  173.  
  174.     BOOL BoxPreviewElem( Environ *, Element3 *, WinMetaFile * );
  175.  
  176.   public:
  177.     SynCamera( int w, int h, double vdvh, double vdvv,
  178.         double vuph, double vupv ) : ViewSys()
  179.     {
  180.       width = w; height = h;
  181.       aspect = (double) w / (double) h;
  182.       fp_flag = TRUE;
  183.       color_type = SC_RGB;
  184.       pass = 0;
  185.       ss_res = SC_None;
  186.       gamma_flag = TRUE;
  187.       jitter_flag = FALSE;
  188.     }
  189.  
  190.     BOOL AntiAliasFlag()
  191.     { return ss_res != SC_None ? TRUE: FALSE; }
  192.     BOOL ContrastFlag() { return renderer.ContrastFlag(); }
  193.     BOOL GammaFlag() { return gamma_flag; }
  194.     BOOL GetStatus() { return jitter.GetStatus(); }
  195.     BOOL IntensityFlag()
  196.     { return renderer.IntensityFlag(); }
  197.     BOOL JitterFlag() { return jitter_flag; }
  198.     BOOL Preview( Environ *, WinMetaFile * );
  199.     BOOL BoxPreview( Environ *, WinMetaFile *, int );
  200.     BOOL Shade( Environ *, WinBitmap * );
  201.     BOOL Shoot( Environ *, WinBitmap *, BOOL * );
  202.     char *GetCurrFilterName();
  203.     char *GetCurrFilterSize();
  204.     char *GetFilterSize( int );
  205.     double GetContrast() { return renderer.GetContrast(); }
  206.     double GetGamma() { return gamma.GetGamma(); }
  207.     double GetIntensity()
  208.     { return renderer.GetIntensity(); }
  209.     int GetColorType() { return color_type; }
  210.     int GetHeight() { return height; }
  211.     int GetWidth() { return width; }
  212.     int GetNoiseLevel() { return jitter.GetNoiseLevel(); }
  213.     int GetMaxPass();
  214.     int GetNumFilters();
  215.     int GetNumPass() { return pass; }
  216.     void Abort();
  217.     void DisableContrast() { renderer.DisableContrast(); }
  218.     void DisableGamma() { gamma_flag = FALSE; }
  219.     void DisableIntensity() { renderer.DisableIntensity(); }
  220.     void DisableJitter() { jitter_flag = FALSE; }
  221.     void EnableContrast() { renderer.EnableContrast(); }
  222.     void EnableGamma() { gamma_flag = TRUE; }
  223.     void EnableIntensity() { renderer.EnableIntensity(); }
  224.     void EnableJitter() { jitter_flag = TRUE; }
  225.     void Reset();
  226.     void SetFilterType( int t ) { ss_res = t; }
  227.     void SetColorType( int t ) { color_type = t; }
  228.     void SetContrast( double c )
  229.     { renderer.SetContrast(c); }
  230.     void SetGamma( double g ) { gamma.SetGamma(g); }
  231.     void SetHeight( int h ) { height = h; }
  232.     void SetIntensity( double i )
  233.     { renderer.SetIntensity(i); }
  234.     void SetNoiseLevel( int n ) { jitter.SetNoiseLevel(n); }
  235.     void SetWidth( int w ) { width = w; }
  236.     void UpdateViewSystem();
  237. };
  238.  
  239. #endif
  240.  
  241.